import {onMounted, ref, watch} from "vue";
import http from "@/commons/utils/httpUtil";

export default function useQuerySzGoodsData(filterOption) {
    // 南山港后台数据集合
    const dbData = ref([]);

    // 查询南山港区货物吞吐量数据
    const queryNsGoodsData = () => {
        http.get('/large/queryNsGoods/' + filterOption.time + '/' + filterOption.year + '/' + filterOption.stats + '/' + '\'南山港区\',\'蛇口集装箱码头有限公司\',\'赤湾集装箱码头有限公司\',\'招商港务（深圳）有限公司\'').then((res) => {
            let isValid = res && res.data && res.data.data && res.data.data.length >= 0;
            dbData.value = isValid ? res.data.data : [];
        });
    }

    onMounted(() => {
        queryNsGoodsData()
    })

    watch(filterOption, queryNsGoodsData)

    return {
        queryNsGoodsData,
        dbData,
    }
}